package com.lcz.googleplay.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.lcz.googleplay.fragment.FragmentFactory;

/**
 * Created by hp on 2016/10/25.
 */

public class FragmentAdapter extends FragmentStatePagerAdapter {
    private String[] tab_name;

    public FragmentAdapter(FragmentManager fm,String[] tab_name) {
        super(fm);
        this.tab_name = tab_name;
    }


    /*每个条目返回的Fragment*/
    @Override
    public Fragment getItem(int position) {
        //通过Fragment工厂类生成fragment
        return FragmentFactory.createFragment(position);
    }

    /*数量*/
    @Override
    public int getCount() {
        return tab_name.length;
    }

    /*每个条目标题*/
    @Override
    public CharSequence getPageTitle(int position) {
        return tab_name[position];
    }
}
